@echo off
setlocal enabledelayedexpansion

REM 设置编译器
set COMPILER=g++

REM 设置源代码和头文件目录
set SRC_DIR=.
set INCLUDE_DIR=head

REM 设置输出文件名
REM set OUTPUT_EXE=TestProgram.exe
set /p OUTPUT_EXE=Enter the name for the executable file (e.g., MyApp.exe):
set LIBRARY_PATH=.
set LIBRARY_NAME=MyLibrary

REM 设置编译选项
set CXXFLAGS_EXE=-Wall -Wextra -std=c++11 -finput-charset=UTF-8 -fexec-charset=GBK

REM 输出变量的值以进行调试
echo Compiler: %COMPILER%
echo Source directory: %SRC_DIR%
echo Include directory: %INCLUDE_DIR%
echo Executable output file: %OUTPUT_EXE%
echo Library path: %LIBRARY_PATH%
echo Library name: %LIBRARY_NAME%
echo Compiler flags for EXE: %CXXFLAGS_EXE%

REM 编译测试程序
%COMPILER% %CXXFLAGS_EXE% -I %INCLUDE_DIR% Main.cpp -L %LIBRARY_PATH% -l %LIBRARY_NAME% -o %OUTPUT_EXE%

REM 检查编译是否成功
if %errorlevel% neq 0 (
    echo Test Program Compilation failed!
    pause
    exit /b
)

REM 运行生成的可执行文件
%OUTPUT_EXE%

pause
